home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4490 / 4490.xpi / components / scripts / nate.js < prev    next >
Text File  |  2010-01-21  |  3KB  |  90 lines

  1. /***********************************************************
  2. nate
  3. ***********************************************************/
  4. var hostString="nate.com";
  5. var supportInboxOnly=true;
  6. var supportShowFolders=true;
  7.  
  8. function init(){
  9.   this.isEmpal=false;
  10.   this.dataURL="http://mail.nate.com";
  11.   this.mailURL="http://mail.nate.com/";
  12.   this.mailDomain="mail.+?.nate.com";  
  13.   var ar=this.user.split("@");
  14.   this.loginData=["https://xo.nate.com/servlets/LoginServlet",
  15.                       "","PASSWD",
  16.                       "redirect="+encodeURIComponent(this.mailURL)
  17.                       +"&ID="+encodeURIComponent(ar[1]=="nate.com"?ar[0]:this.user)+"&domain="+encodeURIComponent(ar[1])];
  18. }
  19. function process(aHttpChannel, aData) {
  20.   switch(this.stage){
  21.   case ST_LOGIN_RES:
  22.     this.getHtml(this.dataURL);
  23.     return false;
  24.   case (ST_LOGIN_RES+1):
  25.     if(aHttpChannel.responseStatus==302){
  26.       this.dataURL=aHttpChannel.getResponseHeader("Location");
  27.     }
  28.     var fnd=aData.match(/<frame src=\"(\S+?)\".+?title=\"hidden\"/);
  29.     if(fnd)this.dataURL=(this.dataURL+fnd[1]).replace(/([^:])\/\//,"$1/");
  30.     this.stage=ST_DATA;
  31.     break;
  32.   }
  33.   return this.baseProcess(aHttpChannel, aData);
  34. }
  35. function getCount(aData){
  36.   return this.mailCount;
  37. }
  38. function getData(aData){
  39.   var obj={}
  40.   if(!this.isEmpal){
  41.     var num=0;
  42.     var found=false;
  43.     if(this.inboxOnly){
  44.       var fnd=aData.match(/mc.unseen={inbox:(\d+)/);
  45.       if(fnd){
  46.         found=true;
  47.         num=parseInt(fnd[1]);        
  48.       }      
  49.     }else{
  50.       var fnd=aData.match(/mc.unseen={(inbox:.+?)}/);      
  51.       if(fnd){
  52.         found=true;
  53.         fnd=fnd[1].match(/:\d+/g);
  54.         for(var i=0;i<fnd.length;i++){
  55.           num+=parseInt(fnd[i].substring(1));
  56.         }        
  57.       }
  58.     }
  59.     if(found){
  60.       var fnd=aData.match(/mbx.addUserMboxes\(\[(\S+?)\]\);/);
  61.       if(fnd){
  62.         var ar=[];
  63.         var re=/\[.*?,.*?,"(.+?)",.*?(\d+)\]/g;
  64.         var o;
  65.         while ((o = re.exec(fnd[1])) != null){
  66.           var n=parseInt(o[2]);
  67.           if(!this.inboxOnly)num+=n;
  68.           if(n>0){
  69.             ar.push(o[1]);
  70.             ar.push(o[2]);
  71.           }
  72.         }
  73.       }
  74.       this.mailCount=num;
  75.       if(this.showFolders){
  76.         if(ar)obj.folders=encodeArray(ar);
  77.       }    
  78.       return obj;
  79.     }
  80.   }
  81.   var fnd=aData.match(/\uc0c8\ud3b8\uc9c0\u0020\ucd1d[\s\S]*?<span[\s\S]*?>(\d+)/);
  82.   if(fnd){
  83.     this.isEmpal=true;
  84.     this.mailCount=parseInt(fnd[1]);
  85.     return obj;
  86.   }
  87.   this.mailCount=-1;
  88.   return obj;
  89. }
  90.